using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class Landmark : EveProperty
    {
        private string landmarkName;
        private string description;
        private int locationId;
        private double x, y, z;
        private double radius;
        private int graphicId;
        private int importance;
        private string url2D;

        private Graphic graphic;
        private EveObject locationObject;
        private Vector location;

        public string Name
        {
            get { return landmarkName; }
        }
        public string Description
        {
            get { return description; }
        }
        public EveObject LocationObject
        {
            get
            {
                if (locationObject == null)
                    locationObject = EveData.GetObject(db, locationId);
                return locationObject;
            }
        }
        public Vector Location
        {
            get
            {
                if (location == null)
                    location = new Vector(x, y, z);
                return location;
            }
        }
        public double Radius
        {
            get { return radius; }
        }
        public Graphic Graphic
        {
            get
            {
                if (graphic == null)
                    graphic = new Graphic(db, graphicId);
                return graphic;
            }
        }
        public int Importance
        {
            get { return importance; }
        }
        public string URL2d
        {
            get { return url2D; }
        }

        internal Landmark(DbDataRow dr)
            : base(dr.Database, EvePropertyType.Landmark, dr["landmarkID"])
        {
            Fill(dr);
        }
        internal Landmark(Database db, int id)
            : base(db, EvePropertyType.Landmark, id)
        {
            Fill(db.ExecuteSingle("SELECT * FROM mapLandmarks WHERE landmarkID=" + id));
        }

        private void Fill(DbDataRow dr)
        {
            landmarkName = dr["landmarkName"];
            description = dr["description"];
            locationId = dr["locationID"];
            x = dr["x"];
            y = dr["y"];
            z = dr["z"];
            radius = dr["radius"];
            graphicId = dr["graphicID"];
            importance = dr["importance"];
            url2D = dr["url2d"];
        }
    }
}
